// 目的：构建解析/过滤流水线，单次遍历逐步处理输入记录。
#include <forward_list>
#include <string>
#include <iostream>

int main() {
    std::forward_list<std::string> stages = {
        "tokenize", "filter-empty", "normalize", "emit"
    };

    std::cout << "Pipeline stages:\n";
    for (const auto& stage : stages) {
        std::cout << " - " << stage << '\n';
    }

    // 插入一个新阶段，在 "normalize" 之后。
    auto prev = stages.before_begin();
    for (auto it = stages.begin(); it != stages.end(); ++it) {
        if (*it == "normalize") {
            stages.insert_after(it, "spell-check");
            break;
        }
        prev = it;
    }

    std::cout << "\nUpdated pipeline:\n";
    for (const auto& stage : stages) {
        std::cout << " - " << stage << '\n';
    }
    return 0;
}